<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>
<script>
	var tables = $('#dataTables').DataTable({
		"sAjaxSource" : '{{ urlfor "OptometryController.DataGrid"}}'
		,"bLengthChange": false
		,"fnServerData" : function(sSource, aoData, fnCallback) {
			var params = checkQueryTableData(aoData)
			$('#search_key').val() ? params.Filter = $('#search_key').val() : ''
			$.post(sSource, JSON.stringify(params),function(resp) {
				fnCallback(resp);
			},'json')
		}
		,columns: [
			{"data" : "DocumentNumber","bSortable": false}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Archives.Number;
            }}
			,{"bSortable": false, render:function(data, type, full, meta) {
				return full.Archives.Realname;
			}}
            ,{"bSortable": false, render:function(data, type, full, meta) {
                    return full.Archives.Mobile;
            }}
			,{"mDataProp" : "Doctor", "bSortable": false}
			,{"mDataProp" : "Optometrist", "bSortable": false}
			,{"mDataProp": "CreatedAt", render:function(data, type, full, meta) {
				return timetrans(data);
			}}
			,{"mDataProp": "CreatedBy", "bSortable": false}
			,{
				"mDataProp": "Action",
				"bSortable": false,
				"sWidth":"12%",
				"render": function ( data, type, full, meta ) {
					btns = '<div class="tpl-table-black-operation">';
					btns += '&nbsp;<a href="/optometry/view/?opt_id='+ full.Id +'" class="am-btn am-btn-secondary am-btn-xs">详情</a>';
					return btns;
				}
			 }
		]
        ,"aLengthMenu":[20, 50, 100, 200]
		,'bLengthChange': true
		,"serverSide": true
		,"bPaginate" : true
		,"bFilter" : false	//是否启动过滤、搜索功能 
		,"bInfo" : true //是否显示页脚信息，DataTables插件左下角显示记录数
		,"bProcessing" : true //DataTables载入数据时，是否显示‘进度’提示  
		  
	});
	
	$("#searchsubmit").bind("click", function () { //点击按钮 触发table重新请求服务器
		$("#dataTables").dataTable().fnDraw(false);
	});

    $(window).keydown(function (event) {
        if(event.keyCode==13){
            var value = $('#search_key').val();
            if(value != '') {
                $("#searchsubmit").click();
            }
        }
    });
</script>